<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/7/8 0008
 * Time: 09:43
 */

namespace app\api\controller\v1\agent;


use app\api\controller\v1\Agent;
use app\currency\service\AgentService;
use think\Db;

class TeamBlacklistLog extends Agent
{

    /**
     * 所属团队被拉黑记录
     */
    public function index()
    {
        $ids = AgentService::getTeamIds($this->aid);
        $where = [['cid','in',$ids]];
        $list = $this->_query('MemberBlacklist')->where($where)->order('create_at desc')->page(true,false,false,10);
        $this->success('success',$list);
    }
    protected function _index_page_filter(&$data)
    {
        $cids = array_unique(array_column($data,'cid'));
        $cleanerList = Db::name('Cleaner')->whereIn('id',$cids)->select();
        foreach ($data as &$datum) {
            $datum['cleaner'] = [];
            foreach ($cleanerList as $cleaner) if ($cleaner['id'] === $datum['cid']) {
                $datum['cleaner'] = $cleaner;
            }
        }
    }
}